#include "Function.hpp"
#include "EquationSolver.hpp"
#include <iostream>
#include <cmath>

const double Pi = acos(-1.);

class F : public Function {
public:
    double operator() (double x) const {
        return x-tan(x);
    }
    double derivative(double x) const {
        double cos_x = cos(x);
        return 1 - 1/pow(cos_x,2);
    }
};

void solve_f() {
    std::cout << "Solving x = tan x near 4.5" << std::endl;
    Newton_Method solver_f_1(F(), 4.5);
    double x1 = solver_f_1.solve();
    std::cout << "A root is: " << x1 << std::endl;

    std::cout << "Solving x = tan x near 7.7" << std::endl;
    Newton_Method solver_f_2(F(), 7.7);
    double x2 = solver_f_2.solve();
    std::cout << "A root is: " << x2 << std::endl;
}

int main() {
    solve_f();
    /* Type your code here */
    return 0;
}